package com.itdct.onflow.system.common.manager

import com.itdct.onflow.core.extend.logInfo
import com.itdct.onflow.system.common.base.BaseManager
import com.itdct.onflow.system.log.mapper.SysApiLogMapper
import org.springframework.stereotype.Component
import java.util.*

/**
 * @author Zhouwx
 * @date 2025/9/23 18:32:38
 * @version 1.0
 * @description
 */
@Component
class CleanExpireLogManager(
    val sysApiLogMapper: SysApiLogMapper
) : BaseManager() {

    fun cleanExpireLog() {
        logInfo("开始清理过期日志")
        val logConfig = onflowConfig.log
        val saveTime = logConfig.saveTime
        val calendar = Calendar.getInstance()
        calendar.add(Calendar.DAY_OF_YEAR, -saveTime)
        val time = calendar.time
        sysApiLogMapper.cleanExpireLog(time)
        logInfo("清理过期日志完成")
    }

}